<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
    <!ENTITY nbsp "&#xA0;">
    <!ENTITY nl "&#xD;&#xA;">
]>

<!-- stylesheet for generating most of the CSS declarations -->

<!-- Version and namespaces -->
<xsl:stylesheet version="1.0"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
    xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
    xmlns:int="http://opendocumentfellowship.org/internal"
    xmlns:math="http://www.w3.org/1998/Math/MathML"
    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
    xmlns:ooo="http://openoffice.org/2004/office"
    xmlns:oooc="http://openoffice.org/2004/calc"
    xmlns:ooow="http://openoffice.org/2004/writer"
    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
    xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
    xmlns:xforms="http://www.w3.org/2002/xforms"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    exclude-result-prefixes="anim chart config dc dr3d draw fo form int math meta number
        office ooo oooc ooow presentation script smil style svg table text xforms xlink #default">

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<!-- /* templates for creating the header (styles) */ -->

    <xsl:template match="style:default-style">
        <xsl:choose>
            <xsl:when test="@style:family='table'"><xsl:text> table</xsl:text></xsl:when>
            <xsl:when test="@style:family='table-cell'"><xsl:text> td</xsl:text></xsl:when>
            <xsl:when test="@style:family='table-row'"><xsl:text> tr</xsl:text></xsl:when>
            <xsl:when test="@style:family='paragraph'"><xsl:text> div</xsl:text></xsl:when> <!-- using div for p tags -->
            <xsl:when test="@style:family='text'"><xsl:text> span</xsl:text></xsl:when>
            <xsl:otherwise>
                <xsl:text>&nl;.default_</xsl:text>
                <xsl:value-of select="translate(@style:family,'.,;: %()[]/\+','_____________')" />
            </xsl:otherwise>
        </xsl:choose>
        <xsl:text> { </xsl:text>
        <xsl:call-template name="readProperties" />
        <xsl:text>}&nl;</xsl:text>
    </xsl:template>

    <xsl:template match="style:style">
        <xsl:text>&nl;.</xsl:text>
        <xsl:call-template name="classInheritance">
            <xsl:with-param name="styleName"><xsl:value-of select="@style:name" /></xsl:with-param>
            <xsl:with-param name="class">
                <xsl:value-of select="translate(@style:name,'.,;: %()[]/\+','_____________')" />
            </xsl:with-param>
            <xsl:with-param name="separator"><xsl:text>.</xsl:text></xsl:with-param><!-- Combined Class Selector -->
        </xsl:call-template>
        <xsl:text> { </xsl:text>
        <xsl:call-template name="readProperties" />
        <xsl:text>} </xsl:text>
    </xsl:template>

    <xsl:template name="readProperties">
        <xsl:apply-templates select="style:page-layout-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:header-footer-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:text-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:paragraph-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:section-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:ruby-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:list-level-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:table-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:table-column-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:table-row-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:table-cell-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:graphic-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:drawing-page-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:chart-properties/@*" mode="styleattr" />
    </xsl:template>

<!-- FORMATTING PROPERTIES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <xsl:template
        match="@fo:background-color | @fo:color | @fo:font-family | @svg:font-family | @fo:font-style |
            @fo:font-variant | @fo:font-weight | @fo:letter-spacing | @fo:text-transform | @fo:text-shadow |
            @fo:text-indent | style:ruby-align"
        mode="styleattr">
        <xsl:value-of select="local-name()" /><xsl:text>: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@fo:font-size" mode="styleattr">
        <!-- be careful on sub/super instances, if it exists, its size takes precedence over the normal font-size -->
        <xsl:if test="not(../@style:text-position) and not(contains(../@style:text-position, ' '))">
            <xsl:text>font-size: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
        </xsl:if>
    </xsl:template>

    <xsl:template match="@style:font-name" mode="styleattr">
        <!-- add single quotes if the value is more than one word -->
        <xsl:variable name="thisValue" select="." />
        <xsl:variable name="thisFont">
            <xsl:choose>
                <xsl:when test="contains(., ' ')">
                     <xsl:value-of select='concat("&apos;", ., "&apos;")' />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="." />
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="thisFontFamily" select="$documentContent/office:font-face-decls/style:font-face[@style:name=$thisValue][1]/@svg:font-family" />
        <xsl:variable name="thisFontGeneric" select="$documentContent/office:font-face-decls/style:font-face[@style:name=$thisValue][1]/@style:font-family-generic" />

        <!-- Get the font to be used from the font-family and font-family-generic listed in the font-face-decls -->
        <xsl:text>font-family: </xsl:text>
        <xsl:value-of select="$thisFont" />
        <xsl:if test="(count($thisFontFamily) &gt; 0) and not($thisFont = $thisFontFamily)">
            <xsl:text>, </xsl:text><xsl:value-of select="$thisFontFamily" />
        </xsl:if>
        <xsl:if test="count($thisFontGeneric) &gt; 0">
            <xsl:text>, </xsl:text><xsl:value-of select="$thisFontGeneric" />
        </xsl:if>
        <xsl:text>; </xsl:text>
    </xsl:template>


    <!-- BORDER, MARGINS, PADDING related properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    <xsl:template match="@fo:border | @fo:border-top | @fo:border-bottom | @fo:border-left | @fo:border-right" mode="styleattr">
        <xsl:variable name="borderType" select="local-name()"/>
        <xsl:choose>
            <xsl:when test=".='none'">
                <xsl:value-of select="$borderType"/>
                <xsl:text>-style: none; </xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:variable name="borderWidth" select="substring-before(., ' ')"/>
                <xsl:variable name="borderStyle" select="substring-before(substring-after(., ' '), ' ')"/>
                <xsl:variable name="borderColor" select="substring-after(substring-after(., ' '), ' ')"/>

               <!-- More information at template 'round-up-border-width' -->
                <xsl:variable name="borderWidthFixed">
                    <xsl:call-template name="round-up-border-width">
                        <xsl:with-param name="borderWidth" select="$borderWidth"/>
                        <xsl:with-param name="multiplier">
                            <xsl:choose>
                                <xsl:when test="$borderStyle = 'double'">3</xsl:when>
                                <xsl:otherwise>1</xsl:otherwise>
                            </xsl:choose>
                        </xsl:with-param>
                    </xsl:call-template>
                </xsl:variable>

                <xsl:value-of select="$borderType"/><xsl:text>-width: </xsl:text>
                <xsl:value-of select="$borderWidthFixed"/><xsl:text>; </xsl:text>
                <xsl:value-of select="$borderType"/><xsl:text>-style: </xsl:text>
                <xsl:value-of select="$borderStyle"/><xsl:text>; </xsl:text>
                <xsl:value-of select="$borderType"/><xsl:text>-color: </xsl:text>
                <xsl:value-of select="$borderColor"/><xsl:text>; </xsl:text>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@style:border-line-width" mode="styleattr">
        <xsl:text>border-width: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:border-line-width-top" mode="styleattr">
        <xsl:text>border-top-width: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:border-line-width-bottom" mode="styleattr">
        <xsl:text>border-bottom-width: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:border-line-width-left" mode="styleattr">
        <xsl:text>border-left-width: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:border-line-width-right" mode="styleattr">
        <xsl:text>border-right-width: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@draw:stroke" mode="styleattr">
        <xsl:text>border-style: </xsl:text>
            <xsl:choose>
                <xsl:when test=".='dash'">dashed</xsl:when>
                <xsl:otherwise><xsl:value-of select="." /></xsl:otherwise>
            </xsl:choose>
        <xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@svg:stroke-width" mode="styleattr">
        <xsl:text>border-width: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@svg:stroke-color" mode="styleattr">
        <xsl:text>border-color: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <!-- Changing border width measure to cm and enlarging border-width to the Mozilla browser(1.7)
         visible minimum width
            - 0.0133cm for solid style
            - 0.0399cm for double style
         as there are three border lines painted -->
    <xsl:template name="round-up-border-width">
        <xsl:param name="borderWidth" />
        <xsl:param name="multiplier" />

        <xsl:variable name="borderWidthByCentimeter">
            <xsl:call-template name="convert2cm">
                <xsl:with-param name="value" select="$borderWidth" />
            </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="minimalBorderWidth" select="0.0133 * $multiplier" />
        <xsl:choose>
            <xsl:when test="number($borderWidthByCentimeter) &lt; $minimalBorderWidth">
                <xsl:value-of select="$minimalBorderWidth" />
                <xsl:text>cm</xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$borderWidthByCentimeter" />
                <xsl:text>cm</xsl:text>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <!-- changing measure to cm -->
    <xsl:template name="convert2cm">
        <xsl:param name="value"/>
        <xsl:variable name="rounding-factor" select="10000"/>
        <xsl:variable name="centimeter-in-mm" select="10"/>
        <xsl:variable name="inch-in-mm" select="25.4"/>
        <xsl:variable name="point-in-mm" select="0.3527778"/>
        <xsl:variable name="dpi" select="111"/>
        <xsl:variable name="pixel-in-mm" select="$inch-in-mm div $dpi"/>
        <xsl:choose>
            <xsl:when test="contains($value, 'mm')">
                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $centimeter-in-mm)) div $rounding-factor"/>
            </xsl:when>
            <xsl:when test="contains($value, 'cm')">
                <xsl:value-of select="substring-before($value, 'cm')"/>
            </xsl:when>
            <xsl:when test="contains($value, 'in')">
                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in') div $centimeter-in-mm * $inch-in-mm)) div $rounding-factor"/>
            </xsl:when>
            <xsl:when test="contains($value, 'pt')">
                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') div $centimeter-in-mm * $point-in-mm)) div $rounding-factor"/>
            </xsl:when>
            <xsl:when test="contains($value, 'px')">
                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $centimeter-in-mm * $pixel-in-mm)) div $rounding-factor"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$value"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- Maps fo:margin as well as fo:margin-top, fo:margin-bottom, fo:padding-left, fo:margin-right -->
    <!-- Maps fo:padding as well as fo:padding-top, fo:padding-bottom, fo:padding-left, fo:padding-right -->
    <xsl:template match="@fo:line-height | @fo:width | @fo:margin | @fo:margin-top | @fo:margin-bottom |
            @fo:margin-left | @fo:margin-right | @fo:padding | @fo:padding-top | @fo:padding-bottom |
            @fo:padding-left | @fo:padding-right | @fo:min-width | @fo:min-height | @fo:max-width | @fo:max-height |
            @style:width" mode="styleattr">
        <xsl:value-of select="local-name()"/><xsl:text>: </xsl:text>
        <xsl:choose>
            <!-- changing the distance measure: inch to in -->
            <xsl:when test="contains(., 'inch')"><xsl:value-of select="substring-before(.,'ch')"/></xsl:when>
            <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
        </xsl:choose>
        <xsl:text>; </xsl:text>
    </xsl:template>


    <!-- ALIGNMENT related properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <xsl:template match="@fo:text-align" mode="styleattr">
        <!-- 'important' is necessary as table cell value alignment is decided by runtime over the valuetype
            Otherwise a table cell style-class would always be outnumbered by the run-time alignment value -->
        <xsl:value-of select="local-name()" /><xsl:text>: </xsl:text>
        <xsl:choose>
            <xsl:when test=".='start'"><xsl:text>left !important</xsl:text></xsl:when>
            <xsl:when test=".='end'"><xsl:text>right !important</xsl:text></xsl:when>
            <xsl:otherwise><xsl:value-of select="." /><xsl:text> !important</xsl:text></xsl:otherwise>
        </xsl:choose>
        <xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:horizontal-pos" mode="styleattr">
        <xsl:choose>
            <!-- We can't support the others until we figure out pagination. -->
            <xsl:when test=".='left'">
                <xsl:text>text-align: left; margin-left: 0px; margin-right: auto; </xsl:text>
            </xsl:when>
            <xsl:when test=".='right'">
                <xsl:text>text-align: right; margin-left: auto; margin-right: 0px; </xsl:text>
            </xsl:when>
            <xsl:when test=".='center'">
                <xsl:text>text-align: center; margin-left: auto; margin-right: auto; </xsl:text>
            </xsl:when>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@draw:textarea-horizontal-align" mode="styleattr">
        <xsl:text>text-align: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:vertical-pos">
        <xsl:choose>
            <xsl:when test=".='from-top'">
                <xsl:text>vertical-align: top; </xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:text>vertical-align: </xsl:text>
                <xsl:value-of select="."/>
                <xsl:text>; </xsl:text>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@draw:textarea-vertical-align | @style:vertical-align" mode="styleattr">
        <xsl:if test="not(.='justify') and not(.='automatic')">
            <xsl:text>vertical-align: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
        </xsl:if>
    </xsl:template>

    <xsl:template match="@style:text-position" mode="styleattr">
        <xsl:variable name="thisValue" select="." />
        <xsl:text>vertical-align: </xsl:text>
        <xsl:choose>
            <xsl:when test="contains($thisValue, ' ')">
                <xsl:value-of select="substring-before($thisValue,' ')" />
                <xsl:text>; </xsl:text>
                <xsl:text>font-size: </xsl:text>
                <xsl:value-of select="substring-after($thisValue,' ')" />
            </xsl:when>
            <xsl:otherwise><xsl:value-of select="$thisValue" /></xsl:otherwise>
        </xsl:choose>
        <xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:ruby-position" mode="styleattr">
        <!-- only the value above (and inline) is supported by CSS -->
        <xsl:if test=".='above'">ruby-position: above; </xsl:if>
    </xsl:template>

    <xsl:template match="@table:align" mode="styleattr">
        <xsl:choose>
            <xsl:when test=".='left'"><xsl:text>float: right; </xsl:text></xsl:when>
            <xsl:when test=".='right'"><xsl:text>float: left; </xsl:text></xsl:when>
            <xsl:otherwise><xsl:text>float: none; </xsl:text></xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@style:writing-mode" mode="styleattr">
        <xsl:choose>
            <xsl:when test="contains(., 'lr')"><xsl:text>direction: ltr; </xsl:text></xsl:when>
            <xsl:when test="contains(., 'rl')"><xsl:text>direction: rtl;</xsl:text></xsl:when>
        </xsl:choose>
    </xsl:template>

    <!-- TEXT rendering related properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <xsl:template match="@style:shadow" mode="styleattr">
        <xsl:text>text-shadow: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:text-underline-style | @style:text-underline-type" mode="styleattr">
       <!-- CSS2 only has one type of underline. TODO: improve this when CSS3 is better supported. -->
         <xsl:if test="not(.='none')"><xsl:text>text-decoration: underline; </xsl:text></xsl:if>
    </xsl:template>

    <xsl:template match="@style:text-line-through-style" mode="styleattr">
        <xsl:if test=".='solid'"><xsl:text>text-decoration: line-through; </xsl:text></xsl:if>
    </xsl:template>

    <xsl:template match="@style:text-blinking" mode="styleattr">
        <xsl:if test=".='true'"><xsl:text>text-decoration: blink; </xsl:text></xsl:if>
    </xsl:template>


    <!-- Width & Height properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <xsl:template match="@style:column-width | @fo:page-width" mode="styleattr">
        <xsl:text>width: </xsl:text>
        <xsl:choose>
            <!-- changing the distance measure: inch to in -->
            <xsl:when test="contains(., 'inch')"><xsl:value-of select="substring-before(.,'ch')"/></xsl:when>
            <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
        </xsl:choose>
        <xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:row-height | @style:min-row-height | @fo:page-height" mode="styleattr">
        <xsl:text>height: </xsl:text>
        <xsl:choose>
            <!-- changing the distance measure: inch to in -->
            <xsl:when test="contains(., 'inch')"><xsl:value-of select="substring-before(.,'ch')"/></xsl:when>
            <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
        </xsl:choose>
        <xsl:text>; </xsl:text>
    </xsl:template>

   <xsl:template match="@table:border-model" mode="styleattr">
        <xsl:choose>
            <xsl:when test=".='collapsing'"><xsl:text>border-collapse: collapse; </xsl:text></xsl:when>
            <xsl:when test=".='separating'"><xsl:text>border-collapse: separate; </xsl:text></xsl:when>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@fo:wrap-option" mode="styleattr">
        <xsl:if test=".='no-wrap'"><xsl:text>white-space: nowrap; </xsl:text></xsl:if>
    </xsl:template>

    <xsl:template match="@style:wrap" mode="styleattr">
        <xsl:choose>
            <xsl:when test=".='left'"><xsl:text>float: right; </xsl:text></xsl:when>
            <xsl:when test=".='right'"><xsl:text>float: left; </xsl:text></xsl:when>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@draw:fill" mode="styleattr">
        <xsl:choose>
            <xsl:when test=".='none'">background-color: transparent; </xsl:when>
            <xsl:when test=".='solid'">
                <xsl:text>background-color: </xsl:text>
                <xsl:value-of select="../@draw:fill-color" />
                <xsl:text>; </xsl:text>
            </xsl:when>
            <xsl:when test=".='bitmap'">
                <xsl:variable name="thisName" select="../@draw:fill-image-name" />
                <xsl:variable name="thisImage"
                        select="$documentStyles/office:styles/draw:fill-image[@draw:name=$thisName][1]/@xlink:href" />
                <xsl:text>background-image: url('</xsl:text>
                <xsl:value-of select='concat($param_imgloc, $thisImage)' />
                <xsl:text>'); </xsl:text>
            </xsl:when>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@text:space-before" mode="styleattr">
        <!-- however, "display: marker" is not yet supported as of Firefox 3, so this doesn't really have an effect -->
        <xsl:text>marker-offset: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>


    <xsl:template match="@*" mode="styleattr">
        <!-- don't output anything for attributes we don't understand -->
    </xsl:template>

    <!-- waiting for CSS3 support; TODO: when the following is supported by firefox from CSS3, uncomment this block
    <xsl:template match="@style:text-outline" mode="styleattr">
        <xsl:if test=".='true'"><xsl:text>font-effect: outline; </xsl:text></xsl:if>
    </xsl:template>

    <xsl:template match="@style:font-relief" mode="styleattr">
        <xsl:choose>
        <xsl:when test=".='embossed'"><xsl:text>font-effect: emboss; </xsl:text></xsl:when>
        <xsl:when test=".='engraved'"><xsl:text>font-effect: engrave; </xsl:text></xsl:when>
        </xsl:choose>
    </xsl:template>
    - end of waiting for CSS3 support items -->

    <xsl:template match="style:background-image">
        <xsl:if test="count(node())>0">
            <xsl:text>background-image: url('</xsl:text>
            <xsl:value-of select="concat($param_imgloc, @xlink:href)"/>
            <xsl:text>'); </xsl:text>
            <xsl:choose>
                <xsl:when test="@style:repeat = 'repeat'"><xsl:text>background-repeat: repeat; </xsl:text></xsl:when>
                <xsl:otherwise><xsl:text>background-repeat: no-repeat; </xsl:text></xsl:otherwise>
            </xsl:choose>
        </xsl:if>
    </xsl:template>

    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <!-- lists properties -->
    <xsl:template match="text:list-style">
        <xsl:for-each select="text:list-level-style-bullet">
            <xsl:text>&nl;.</xsl:text>
            <xsl:value-of select="concat(translate(../@style:name,'.,;: %()[]/\+','_____________'), '_', @text:level)" />
            <xsl:text> { </xsl:text>
            <xsl:choose>
                <xsl:when test="@text:bullet-char='•'"><!-- BULLET (U+2022) -->
                    <xsl:text>list-style-type: disc; list-style-image: none; </xsl:text>
                </xsl:when>
                <xsl:when test="@text:bullet-char='●'"><!-- BLACK CIRCLE (U+25CF) -->
                    <xsl:text>list-style-type: disc; list-style-image: none; </xsl:text>
                </xsl:when>
                <xsl:when test="@text:bullet-char='✔'"><!-- HEAVY CHECK MARK (U+2714) -->
                    <xsl:text>list-style-image: url('chrome://odfview/content/bullets/bullet-check.gif'); </xsl:text>
                </xsl:when>
                <xsl:when test="@text:bullet-char='✗'"><!-- BALLOT X (U+2717) -->
                    <xsl:text>list-style-image: url('chrome://odfview/content/bullets/bullet-x.gif'); </xsl:text>
                </xsl:when>
                <xsl:when test="@text:bullet-char='➔'"><!-- HEAVY WIDE-HEADED RIGHTWARDS ARROW (U+2794) -->
                    <xsl:text>list-style-image: url('chrome://odfview/content/bullets/bullet-arrow.gif'); </xsl:text>
                </xsl:when>
                <xsl:when test="@text:bullet-char='➢'"><!-- THREE-D TOP-LIGHTED RIGHTWARDS ARROWHEAD (U+27A2) -->
                    <xsl:text>list-style-image: url('chrome://odfview/content/bullets/bullet-3d-arrow.gif'); </xsl:text>
                </xsl:when>
                <xsl:when test="@text:bullet-char=''"><!-- diamond ◆ -->
                    <xsl:text>list-style-image: url('chrome://odfview/content/bullets/bullet-diamond.gif'); </xsl:text>
                </xsl:when>
                <xsl:when test="@text:bullet-char=''"><!-- square ◼ -->
                    <xsl:text>list-style-type: square; list-style-image: none; </xsl:text>
                </xsl:when>
                <xsl:when test='@text:bullet-char="●"'><!-- blank -->
                    <xsl:text>list-style-type: none; list-style-image: none; </xsl:text>
                </xsl:when>
                <xsl:when test="@text:level mod 3 = 1"><!-- for uncommon bullets, use the basic ones based on level -->
                    <xsl:text>list-style-type: disc; list-style-image: none; </xsl:text>
                </xsl:when>
                <xsl:when test="@text:level mod 3 = 2"><!-- for uncommon bullets, use the basic ones based on level -->
                    <xsl:text>list-style-type: circle; list-style-image: none; </xsl:text>
                </xsl:when>
                <xsl:when test="@text:level mod 3 = 0"><!-- for uncommon bullets, use the basic ones based on level -->
                    <xsl:text>list-style-type: square; list-style-image: none; </xsl:text>
                </xsl:when>
                <xsl:otherwise><!-- (default) -->
                    <xsl:text>list-style-type: decimal; list-style-image: none; </xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:apply-templates select="style:list-level-properties/@*" mode="styleattr" />
            <xsl:apply-templates select="style:text-properties/@*" mode="styleattr" />
            <xsl:text> }</xsl:text>
        </xsl:for-each>

        <xsl:for-each select="text:list-level-style-image">
            <xsl:text>&nl;.</xsl:text>
            <xsl:value-of select="concat(translate(../@style:name,'.,;: %()[]/\+','_____________'), '_', @text:level)" />
            <xsl:text> { </xsl:text>
            <xsl:if test="@xlink:href">
                <xsl:text>list-style-image: url('</xsl:text>
                <xsl:value-of select="concat($param_imgloc, @xlink:href)" />
                <xsl:text>'); </xsl:text>
            </xsl:if>
            <xsl:text>}</xsl:text>
        </xsl:for-each>

        <xsl:for-each select="text:list-level-style-number">
            <xsl:text>&nl;.</xsl:text>
            <xsl:value-of select="concat(translate(../@style:name,'.,;: %()[]/\+','_____________'), '_', @text:level)" />
            <xsl:text> { list-style-type: </xsl:text>
            <xsl:choose>
                <xsl:when test="@style:num-format='1' and @style:num-prefix='0'">decimal-leading-zero</xsl:when>
                <xsl:when test="@style:num-format='1'">decimal</xsl:when>
                <xsl:when test="@style:num-format='I'">upper-roman</xsl:when>
                <xsl:when test="@style:num-format='i'">lower-roman</xsl:when>
                <xsl:when test="@style:num-format='A'">upper-alpha</xsl:when>
                <xsl:when test="@style:num-format='a'">lower-alpha</xsl:when>
                <xsl:otherwise>decimal</xsl:otherwise>
            </xsl:choose>
            <xsl:text>; list-style-image: none; }</xsl:text>
        </xsl:for-each>
    </xsl:template>

<!-- - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -->

</xsl:stylesheet>
